<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // Object.prototype.toString.call(obj)
      function aa(obj, formData) {
        if (!obj) {
          return null;
        } else {
          if (typeof obj === 'object') {
            if (Array.isArray(obj)) {
              for (let i = 0; i < obj.length; i++) {}
            } else {
              // 单个对象
              for (let key in obj) {
                let value = obj[key];
                if (value && typeof value === 'object') {
                  // 递归
                  aa(value);
                } else {
                  formData.append(key, obj[key]);
                }
              }
            }
          }
        }
      }
      var obj = {
        description: '',
        file: null,
        title: '',
        // 动态添加部分数据
        chapterList: [
          {
            title: '',
            file: null,
            description: '',
          },
        ],
      };
      var formData = new FormData();
      formData.append();
    </script>
  </body>
</html>
